package mygameclient;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

public class PlayersPanel extends JPanel{

    static ArrayList<Player> players = new ArrayList<Player>();
    JTable table;

    public PlayersPanel(){

        PlayerTableModel pModel = new PlayerTableModel(players);
        table = new JTable(pModel);
        table.setPreferredScrollableViewportSize(new Dimension(300, 360));
        table.setFillsViewportHeight(true);
        JScrollPane sclPane = new JScrollPane(table);
        add(sclPane, BorderLayout.CENTER);
    }

    public Player getPlayer(){
        int playerIndex = table.getSelectedRow();
        Player player = players.get(playerIndex);
        return player;
    }
}
